package com.joysuch.wwyt.mh.service.impl;

import com.joysuch.wwyt.mh.entity.TagValueItem;
import com.joysuch.wwyt.mh.entity.WindVaneData;
import com.joysuch.wwyt.mh.mapper.CustomizeMonitorTypeMapper;
import com.joysuch.wwyt.mh.service.WindVaneDataService;
import jodd.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zero
 * @since 2021/8/3 10:12
 */
@Service
public class WindVaneDataServiceImpl implements WindVaneDataService {
    
    @Autowired
    private CustomizeMonitorTypeMapper customizeMonitorTypeMapper;
    
    @Override
    public Object simulationData(String code) {
        Map<String,Object> map = new HashMap<>();
        String orgCode = customizeMonitorTypeMapper.getOrgCodeByPoint(code);
        if(StringUtil.isBlank(orgCode)){
            map.put("code",400);
            map.put("msg","无法查找到此监测点。请重试");
            map.put("data","");
            map.put("dataList","");
            map.put("count",0);
            return map;
        }
        WindVaneData windVaneData = new WindVaneData();
        windVaneData.setTagCode(orgCode);
        windVaneData.setRemark("");
        windVaneData.setTagHtml("<div data-v-01faff0e=\"\" data-v-22a17378=\"\" style=\"height: 180px;\"><div data-v-01faff0e=\"\" class=\"dialog_head tab_name\"><span data-v-01faff0e=\"\" class=\"\">监测点信息</span> <!----></div> <div data-v-01faff0e=\"\" class=\"el-scrollbar\" style=\"height: calc(100% - 40px);\"><div class=\"el-scrollbar__wrap el-scrollbar__wrap--hidden-default\"><div class=\"el-scrollbar__view\"><div data-v-22a17378=\"\" class=\"card_detail item_font\"><div data-v-22a17378=\"\" class=\"item_container\"><div data-v-22a17378=\"\" class=\"item_c\"><span data-v-22a17378=\"\" class=\"item_label\">省</span><span data-v-22a17378=\"\" title=\"宁夏\" class=\"item_value\">宁夏</span></div> <div data-v-22a17378=\"\" class=\"item_c\"><span data-v-22a17378=\"\" class=\"item_label\">市</span><span data-v-22a17378=\"\" title=\"沙坡头区\" class=\"item_value\">沙坡头区</span></div></div> <div data-v-22a17378=\"\" class=\"item_container\"><div data-v-22a17378=\"\" class=\"item_c\"><span data-v-22a17378=\"\" class=\"item_label\">风向</span><span data-v-22a17378=\"\" class=\"item_value\">东风</span></div> <div data-v-22a17378=\"\" class=\"item_c\"><span data-v-22a17378=\"\" class=\"item_label\">风力</span><span data-v-22a17378=\"\" class=\"item_value\">4</span></div></div> <div data-v-22a17378=\"\" class=\"item_container\"><div data-v-22a17378=\"\" class=\"item_c\"><span data-v-22a17378=\"\" class=\"item_label\">温度</span><span data-v-22a17378=\"\" class=\"item_value\">38</span></div> <div data-v-22a17378=\"\" class=\"item_c\"><span data-v-22a17378=\"\" class=\"item_label\">天气</span><span data-v-22a17378=\"\" class=\"item_value\">晴</span></div></div> <div data-v-22a17378=\"\" class=\"item_container\"><div data-v-22a17378=\"\" class=\"item_c\"><span data-v-22a17378=\"\" class=\"item_label\">湿度</span><span data-v-22a17378=\"\" class=\"item_value\">43</span></div> <div data-v-22a17378=\"\" class=\"item_c\"><span data-v-22a17378=\"\" class=\"item_label\">-</span><span data-v-22a17378=\"\" class=\"item_value\">-</span></div></div></div></div></div><div class=\"el-scrollbar__bar is-horizontal\"><div class=\"el-scrollbar__thumb\" style=\"transform: translateX(0%);\"></div></div><div class=\"el-scrollbar__bar is-vertical\"><div class=\"el-scrollbar__thumb\" style=\"transform: translateY(0%);\"></div></div></div></div>");
        List<TagValueItem> tagValueItemList = new ArrayList<>();
        TagValueItem tagValueItem1 = new TagValueItem("province","省","宁夏");
        TagValueItem tagValueItem2 = new TagValueItem("adcode","监测点编号",code);
        TagValueItem tagValueItem3 = new TagValueItem("city","城市","中卫");
        TagValueItem tagValueItem4 = new TagValueItem("temperature","温度","24");
        TagValueItem tagValueItem5 = new TagValueItem("weather","天气","晴");
        TagValueItem tagValueItem6 = new TagValueItem("humidity","湿度","43");
        TagValueItem tagValueItem7 = new TagValueItem("reporttime","监测时间","2021-06-10 13:36:24");
        TagValueItem tagValueItem8 = new TagValueItem("winddirection","风向","东");
        tagValueItemList.add(tagValueItem1);
        tagValueItemList.add(tagValueItem2);
        tagValueItemList.add(tagValueItem3);
        tagValueItemList.add(tagValueItem4);
        tagValueItemList.add(tagValueItem5);
        tagValueItemList.add(tagValueItem6);
        tagValueItemList.add(tagValueItem7);
        tagValueItemList.add(tagValueItem8);
        windVaneData.setTagValue(tagValueItemList);
        map.put("code",200);
        map.put("msg","");
        map.put("data",windVaneData);
        map.put("dataList","");
        map.put("count",0);
        return map;
    }
}
